{ Siberian Olympiad. 3 stage.
  Problemset: http://agul-problems1.googlecode.com/svn/trunk/2010-2011/wso/stage3/wso_3stage.pdf
  Problem 3
  Points: 100
}
var n,u,i,j,m,k,l:longint; w:array[1..10010,1..2] of integer; B:array[1..10010] of integer; A:array[1..10010,1..10010] of boolean;
procedure dfs(t:longint);
var j:longint;
begin
B[t]:=1;
if t<>1 then A[t][u]:=false;
for j:=1 to n do begin
  if A[t,j] and(B[j]=0) then begin
    u:=t;
    DFS(j);
  end;
  if A[t,j] and(B[j]=1) then A[j,t]:=false;
end;
end;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,m);
fillchar(a,sizeof(a),false);
for i:=1 to m do begin
  read(k,l);
  A[k][l]:=true;
  A[l][k]:=true;
  w[i][1]:=k;
  w[i][2]:=l;
end;
dfs(1);
for i:=1 to m do begin
  if A[w[i][1],w[i][2]] then writeln(w[i][1],' ',w[i][2]);
  if A[w[i][2],w[i][1]] then writeln(w[i][2],' ',w[i][1]);
end;
end.